<%--
    Document   : booking_rightpanel
    Created on : Nov 15, 2008, 11:33:04 PM
    Author     : cipher
--%>

<%@ page language="java" import="java.util.*,common.*,Booking.*, FlightSelect.*, flight.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setCharacterEncoding("UTF-8");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Ticket booking</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAOypY6k-8wPRekCAdGgjT5BT2yXp_ZAY8_ufC3CFXhHIE1NvwkxS9aKwpi2_XVE_p8Bl5AEWgba8wZg" type="text/javascript"></script>
<script type="text/javascript">
    var map = null;
    var geocoder = null;
	var point_a = null;
	var point_b = null;
	var zoom_level = 5;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
		map.setMapType(G_HYBRID_MAP);
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        geocoder = new GClientGeocoder();
      }
    }

	var distances = new Array();
	function getDistance(from,to){
		var from_point;
		var to_point;

		geocoder = new GClientGeocoder();
		map = new GMap2(document.getElementById("map_canvas"));
		map.setMapType(G_HYBRID_MAP);
		geocoder.getLatLng(from, function(point){

			from_point = point;
			geocoder.getLatLng(to, function(point){

				to_point = point;
				map.setCenter(from_point,13);
				alert("here")
				window.dis = from_point.distanceFrom(to_point);
				//return window.dis;
			});

		});
		//while(window.dis==null){}
		alert(window.dis);
		return window.dis;
	}

    function showAddress(address) {
	  var a_address = address.split(";");

	  for(var i = 0; a_address.length > i; i++){

        if (geocoder) {
          geocoder.getLatLng(
            a_address[i],
            function(point) {
              if (!point) {
                alert(a_address[i] + " not found");
              } else {
                map.setCenter(point, zoom_level);
                var marker = new GMarker(point);
                map.addOverlay(marker);
               // marker.openInfoWindowHtml("The address is: "+a_address[i]);

			    point_b = point_a;
			    point_a = point;
			    if(point_a != null && point_b != null){
				  var opts = {clickable:true,geodesic:true};
				  var polyline = new GPolyline([point_a,point_b],"#ff0000", 5, .5, opts);
	  			  map.addOverlay(polyline);
		  	    }
              } // else
            } // function
          );
        }   // if(geocoder)
	  }  // for loop
    }
</script> 
<style type="text/css">
<!--
.STYLE2 {
	font-size: 18px;
	font-weight: bold;
}
.STYLE3 {color: #000000}
.style6 {font-size: 16px}
-->
</style>
</head>

<%
    String cityString = (String)request.getAttribute("cityString");
%>
<body onload="initialize()" onunload="GUnload()">
<form name="booking_form" method="post" action="/afirs/Booking/BookingServlet">
<table width="100%" border="0" cellspacing="0" cellpadding="1" style="background-color: #000000;">
  <tr>
    <td><table width="100%" border="0" cellpadding="8" cellspacing="0" style="background-color: #cccccc;">
      <tr>
        <td height="30" bgcolor="#9966FF" style="background-color: #9966FF;color: #cccccc"><div align="center" class="STYLE2 STYLE3">Booking</div></td>
      </tr>
      <tr>
        <td height="29" bgcolor="#FFFFFF"><p align="center"><strong>For your security,  we use standard SSL encryption to protect the transfer of your payment  information. Read our privacy policy.</strong></p></td>
      </tr>
    </table></td>
  </tr>
</table>

<table align="center" bgcolor="#008800" border="0" cellspacing="2" cellpadding="5" width=100%>

      <tr bgcolor="#cc99cc">
        <td height="30" colspan="8" bgcolor="#9966FF">Iternary-Round/Single Trip, Here is your options:</td>
    </tr>
      <tr bgcolor="#cc99cc">

       <td height="34" bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Direction</strong></P></td>
       <td width="189" bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Depart City</strong></P></td>
       <td width="184" bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Arrive City</strong></P></td>
       <td width="130" bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Airline Name</strong></P></td>
       <td bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Flight Number</strong></P></td>
       <td bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Departure date</strong></P></td>
       <td bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Arrival date</strong></P></td>
       <td width="165" bgcolor="#0099FF"><P align="center" class="STYLE1"><strong>Price</strong></P></td>
    </tr>
<%
	PageBean pageCtl = (PageBean)request.getAttribute("pageCtl");
    PageBean pageCtl2 = null;
    
    FlightBean fb = (FlightBean)request.getAttribute("fb");
    int NumOfTicket = fb.getNoOfTickets();
    int pricetotal = ((Integer)request.getAttribute("pricetotal")).intValue();
    FlightSelectBean departID = (FlightSelectBean)request.getAttribute("departFlight");
    FlightSelectBean returnID = null;

    if (fb.getTripType() == 1) {//round trip type

        returnID = (FlightSelectBean)request.getAttribute("returnFlight");
        pageCtl2 = (PageBean)request.getAttribute("pageCtl2");
    }

    String currentType = (String)session.getAttribute("currentType");
  	java.util.Vector v = pageCtl.getResult();
        String CardType = pageCtl.CardType;//should be replaced by user name using Attribute

  	java.util.Enumeration e = v.elements();
        int ID = 0;
        int cnt = 0;
        Object[] obj = new Object[10];
        
  	while(e.hasMoreElements())
	{
            obj = (Object[])e.nextElement();
            String type = (String)obj[0];
            String str = (String)obj[7];
            String strr = (String)obj[8];
            ID = Integer.parseInt(strr);
%>
            <tr bgcolor="#CCFFFF">
            <td width="82" height="48" align="center">	Depart </td>
            <td align="center"><%=obj[0]%></td>
            <td align="center" width="184"><%=obj[1]%></td>
            <td align="center">
              <%=obj[2]%></td>
            <td align="center" width="106"><%=obj[3]%></td>
            <td align="center" width="191"><%=obj[4]%></td>
            <td align="center" width="200"><%=obj[5]%></td>
            <td align="center"><%=obj[6]%></td>
		    </tr>
<%
            cnt++;
	}


    if (fb.getTripType() == 1) {
    v = pageCtl2.getResult();
    e = v.elements();
    obj = new Object[10];
    cnt = 0;

    while(e.hasMoreElements())
	{
            obj = (Object[])e.nextElement();
            String type = (String)obj[0];
            String str = (String)obj[7];
            String strr = (String)obj[8];
            ID = Integer.parseInt(strr);

%>
            <tr bgcolor="#CCFFFF">
            <td width="82" height="48" align="center">	Return </td>
            <td align="center"><%=obj[0]%></td>
            <td align="center" width="184"><%=obj[1]%></td>
            <td align="center">
              <%=obj[2]%></td>
            <td align="center" width="106"><%=obj[3]%></td>
            <td align="center" width="191"><%=obj[4]%></td>
            <td align="center" width="200"><%=obj[5]%></td>
            <td align="center"><%=obj[6]%></td>
		    </tr>
<%
            cnt++;
	}
    }
%>
<tr bgcolor="#CCFFFF">
              <td colspan="6" rowspan="2" align="center">&nbsp;</td>
              <td height="48" align="center" bgcolor="#0099FF"><strong>Number of Passeners </strong></td>
              <td align="center"><%=NumOfTicket%></td>
            </tr>
            <tr bgcolor="#CCFFFF">
              <td height="48" align="center" bgcolor="#0099FF"><strong>Total Price </strong></td>
              <td align="center"><%=pricetotal%></td>
            </tr>
</table>

<%
    if (CardType != null) {//should be replaced by user name using Attribute
%>
<table width="100%" border="0" cellspacing="0" cellpadding="1" style="background-color: #000000;">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="8">
      <tr>
        <td height="30" colspan="3" bgcolor="#9966FF" style="color: #cccccc;"><div align="center"><span class="STYLE2 STYLE3">Existing Card Information</span></div></td>
        </tr>
      <tr>
        <td width="14%" bgcolor="#FFFFFF" style="background-color: #cccccc;">Card Number: <%=pageCtl.CardNumber%></td>

      </tr>
      <tr>
        <td width="14%" bgcolor="#FFFFFF" style="background-color: #cccccc;">Card Type: <%=pageCtl.CardType%></td>

      </tr>

      <tr>
        <td bgcolor="#FFFFFF" style="background-color: #cccccc;">CardHolder's Name : <%=pageCtl.UserID%></td>

      </tr>
      <tr>
        <td bgcolor="#FFFFFF" style="background-color: #cccccc;">Email Address: <%=pageCtl.UserID%></td>

      </tr>
      </table></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="1" style="background-color: #000000;">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="8">
      <tr>
        <td height="30" colspan="2" bgcolor="#9966FF" style="color: #cccccc;"><div align="center"><span class="STYLE2 STYLE3">Existing Billing Address</span></div></td>
      </tr>
      <tr>
        <td width="14%" style="background-color: #cccccc;">Address Line1: <%=pageCtl.UserAddr%></td>
        
      </tr>

      <tr>
        <td style="background-color: #cccccc;">City: <%=pageCtl.City%></td>
        
      </tr>
      <tr>
        <td style="background-color: #cccccc;">State: <%=pageCtl.State%></td>

      </tr>
      <tr>
        <td style="background-color: #cccccc;">ZipCode: <%=pageCtl.ZipCode%></td>

        <input type="hidden" name="maxID" value=<%=ID%> />
        <input type="hidden" name="indicator" value="1" />

      </tr>
    </table></td>
  </tr>
  </table>

<%  }
    else {
%>

<table width="100%" border="0" cellspacing="0" cellpadding="4" bgcolor="#CCCCCC">
  <tr>
    <td height="30" bgcolor="#9966FF"><div align="center"><span class="STYLE2 STYLE3 style6">Payment Options</span></div></td>
  </tr>
</table>

  <p>
    <label>
      <input type="radio" name="RadioGroup2" value="0" />
      Master Card</label>

    <label>
    <img src="images/mastercard_logo_4.gif" width="65" height="41" alt="master" />
    <input type="radio" name="RadioGroup2" value="1" />
      Visa</label>

    <label>
      <img src="images/visa_logo_2.gif" width="57" height="36" alt="visa" />
      <input type="radio" name="RadioGroup2" value="2" />
      AmericanExpress</label>
      <img src="images/americanexpress.jpg" width="57" height="36" alt="americanexpress" />

    <br />
  </p>

<table width="100%" border="0" cellspacing="0" cellpadding="1" style="background-color: #000000;">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="8">
      <tr>
        <td height="30" colspan="3" bgcolor="#9966FF" style="color: #cccccc;"><div align="center"><span class="STYLE2 STYLE3 style6">Card Information</span></div></td>
        </tr>
      <tr>
        <td width="14%" height="30" bgcolor="#FFFFFF" style="background-color: #cccccc;">Card Number</td>
        <td height="30" colspan="2" bgcolor="#FFFFFF" style="background-color: #cccccc;"><input type="text" name="cardnumber" id="cardnumber" /></td>
      </tr>
      
      <tr>
        <td bgcolor="#FFFFFF" style="background-color: #cccccc;">Expiration Date</td>
        <td width="8%" bgcolor="#FFFFFF" style="background-color: #cccccc;"><select name="exmonth">
          <option value="01">January</option>
          <option value="02">February</option>
          <option value="03">March</option>
          <option value="04">April</option>
          <option value="05">May</option>
          <option value="06">June</option>
          <option value="07">July</option>
          <option value="08">August</option>
          <option value="09">September</option>
          <option value="10">October</option>
          <option value="11">November</option>
          <option value="12" selected>December</option>
        </select></td>
        <td width="78%" bgcolor="#FFFFFF" style="background-color: #cccccc;"><select name="exyear">
          <option value="09" selected>2009</option>
          <option value="10">2010</option>
          <option value="11">2011</option>
          <option value="12">2012</option>
          <option value="13">2013</option>
          <option value="14">2014</option>
          <option value="15">2015</option>
        </select></td>
      </tr>
      
    </table></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="1" style="background-color: #000000;">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="8">
      <tr>
        <td height="30" colspan="2" bgcolor="#9966FF" style="color: #cccccc;"><div align="center"><span class="STYLE2 STYLE3 style6">Billing Address</span></div></td>
      </tr>
      <tr>
        <td width="14%" style="background-color: #cccccc;">Address Line1</td>
        <td width="86%" style="background-color: #cccccc;"><input type="text" name="Add1" /></td>
      </tr>
      <tr>
        <td style="background-color: #cccccc;">Address Line2</td>
        <td style="background-color: #cccccc;"><input type="text" name="Add2" /></td>
      </tr>
      <tr>
        <td style="background-color: #cccccc;">City</td>
        <td style="background-color: #cccccc;"><input type="text" name="city" /></td>
      </tr>
      <tr>
        <td style="background-color: #cccccc;">State</td>
        <td style="background-color: #cccccc;"><select name="state" size="1">
	<option value="AK" selected>AK</option>
	<option value="AL">AL</option>
	<option value="AR">AR</option>
	<option value="AZ">AZ</option>
	<option value="CA">CA</option>
	<option value="CO">CO</option>
	<option value="CT">CT</option>
	<option value="DC">DC</option>
	<option value="DE">DE</option>
	<option value="FL">FL</option>
	<option value="GA">GA</option>
	<option value="HI">HI</option>
	<option value="IA">IA</option>
	<option value="ID">ID</option>
	<option value="IL">IL</option>
	<option value="IN">IN</option>
	<option value="KS">KS</option>
	<option value="KY">KY</option>
	<option value="LA">LA</option>
	<option value="MA">MA</option>
	<option value="MD">MD</option>
	<option value="ME">ME</option>
	<option value="MI">MI</option>
	<option value="MN">MN</option>
	<option value="MO">MO</option>
	<option value="MS">MS</option>
	<option value="MT">MT</option>
	<option value="NC">NC</option>
	<option value="ND">ND</option>
	<option value="NE">NE</option>
	<option value="NH">NH</option>
	<option value="NJ">NJ</option>
	<option value="NM">NM</option>
	<option value="NV">NV</option>
	<option value="NY">NY</option>
	<option value="OH">OH</option>
	<option value="OK">OK</option>
	<option value="OR">OR</option>
	<option value="PA">PA</option>
	<option value="RI">RI</option>
	<option value="SC">SC</option>
	<option value="SD">SD</option>
	<option value="TN">TN</option>
	<option value="TX">TX</option>
	<option value="UT">UT</option>
	<option value="VA">VA</option>
	<option value="VT">VT</option>
	<option value="WA">WA</option>
	<option value="WI">WI</option>
	<option value="WV">WV</option>
	<option value="WY">WY</option>
</select></td>
      </tr>
      <tr>
        <td style="background-color: #cccccc;">ZipCode</td>
        <td style="background-color: #cccccc;"><input type="text" name="zipcode" />
          <input type="hidden" value=<%=ID%> name="maxID" />
          <input type="hidden" name="indicator" value="0" /></td>
      </tr>
      
      
    </table></td>
  </tr>

  <label></label>
   
  </table>
 <% }
     session.setAttribute("departFlight", departID);
     session.setAttribute("returnFlight", returnID);
     session.setAttribute("fb",fb);
     session.setAttribute("pricetotal", pricetotal);
    %>
 <input type="submit" name="Submit" value="Submit" />
</form>

<form action="#" onsubmit="showAddress(this.address.value); return false">
  <p><input type="text" size="60" name="address" value="<%=cityString%>" />
  <input type="submit" value="Show" /> </p>
  <div id="map_canvas" style="width: 500px; height: 300px"></div>
</form>

<%--
<form name="submit_selected" method="post" action="/afirs/FlightSelect/FlightSelectServlet">

        <input type="hidden" name="choose_flight" value=<%=obj[9]%>>
    <input type="hidden" value="1" name="reset" />
    <input type="submit" name="Reset" value="Reset" />
</form>
--%>

<p>&nbsp;</p>
</body>
</html>